package sprites;

import java.awt.Point;

import util.DrawSet;

public class LineSprite extends PointSetSprite {
	private Point	end = new Point(0,0);
	private boolean isUpdating = false;
	
	public LineSprite(Point start, Point end) {
		super(start, DrawSet.getLine(start.x, start.y, end.x, end.y));
		this.end = end;
		
		update();
	}
	
	public Point getEnd() {
		return end;
	}

	public void setEnd(Point end) {
		this.end = end;
		update();
	}

	public Point getStart() {
		return getPos();
	}

	public void setStart(Point start) {
		super.setPos(start);
		update();
	}

	private void update() {
		if (!isUpdating) {
			isUpdating = true;
			setPoints(
				DrawSet.getLine(
					getStart().x, 
					getStart().y, 
					getEnd().x, 
					getEnd().y
				)
			);

		}
	}
}
